import pymysql
##注意！
##运行该py  请先执行sql脚本！

#实现宿舍号按规律自增 101到201....
class InitMysql():
    db = pymysql.connect(host='localhost', user='root', password='root', port=3306, database='drom_student')
    # 创建可执行游标
    cursor = db.cursor()
    Did=101
    for i in range(1,60):
        sql = "insert into drom_information(Did) values('%d');" % Did
        cursor.execute(sql)
        db.commit()
        Did=Did+1
        if Did % 10==0:
            Did=Did+91


InitMysql()  # 给宿舍表里面插入宿舍号